From 9448593a8ace5d7866ccc678052fc3877ae501ff Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Thu, 20 Mar 2003 22:01:55 +0000 Subject: [PATCH] bitkeeper revision 1.153 (3e7a3a53LJF3EAuJITGpo9ybSgxf2w) config.h, domain.c, dom_mem_ops.c, TODO: Fixed out of memory handling so we don't hang. Updated TODO file. --- xen/TODO | 16 ++++++++++++---- xen/common/dom_mem_ops.c | 20 +++++++++++++++----- xen/common/domain.c | 9 +++++++-- xen/include/xeno/config.h | 6 ++++++ 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/xen/TODO b/xen/TODO index e81023e995..41f0fca7d5 100644 --- a/xen/TODO +++ b/xen/TODO @@ -44,7 +44,15 @@ order to requests, just as we already do with block-device rings. We'll need to add an opaque identifier to ring entries, allowing matching of requests and responses, but that's about it. -4. GDT AND LDT VIRTUALISATION +4. NETWORK CHECKSUM OFFLOAD +--------------------------- +All the NICs that we support can checksum packets on behalf of guest +OSes. We need to add appropriate flags to and from each domain to +indicate, on transmit, which packets need the checksum added and, on +receive, which packets have been checked out as okay. We can steal +Linux's interface, which is entirely sane given NIC limitations. + +5. GDT AND LDT VIRTUALISATION ----------------------------- We do not allow modification of the GDT, or any use of the LDT. This is necessary for support of unmodified applications (eg. Linux uses @@ -55,14 +63,14 @@ I have some text on how to do this: /usr/groups/xeno/discussion-docs/memory_management/segment_tables.txt It's already half implemented, but the rest is still to do. -5. DOMAIN 0 MANAGEMENT DAEMON +6. DOMAIN 0 MANAGEMENT DAEMON ----------------------------- A better control daemon is required for domain 0, which keeps proper track of machine resources and can make sensible policy choices. This may require support in Xen; for example, notifications (eg. DOMn is killed), and requests (eg. can DOMn allocate x frames of memory?). -6. ACCURATE TIMERS AND WALL-CLOCK TIME +7. ACCURATE TIMERS AND WALL-CLOCK TIME -------------------------------------- Currently our long-term timebase free runs on CPU0, with no external calibration. We should run ntpd on domain 0 and allow this to warp @@ -70,7 +78,7 @@ Xen's timebase. Once this is done, we can have a timebase per CPU and not worry about relative drift (since they'll all get sync'ed periodically by ntp). -7. NEW DESIGN FEATURES +8. NEW DESIGN FEATURES ---------------------- This includes the last-chance page cache, and the unified buffer cache. diff --git a/xen/common/dom_mem_ops.c b/xen/common/dom_mem_ops.c index e919311c5c..07f7cf8f7d 100644 --- a/xen/common/dom_mem_ops.c +++ b/xen/common/dom_mem_ops.c @@ -29,14 +29,24 @@ static long alloc_dom_mem(struct task_struct *p, balloon_def_op_t bop) unsigned long i; unsigned long flags; - /* POLICY DECISION: Each domain has a page limit. */ - if( (p->tot_pages + bop.size) > p->max_pages ) + /* + * POLICY DECISION: Each domain has a page limit. + * NB. The first part of test is because bop.size could be so big that + * tot_pages + bop.size overflows a u_long. + */ + if( (bop.size > p->max_pages) || + ((p->tot_pages + bop.size) > p->max_pages) ) return -ENOMEM; - if ( free_pfns < bop.size ) - return -ENOMEM; - spin_lock_irqsave(&free_list_lock, flags); + + if ( free_pfns < (bop.size + (SLACK_DOMAIN_MEM_KILOBYTES << + (PAGE_SHIFT-10))) ) + { + spin_unlock_irqrestore(&free_list_lock, flags); + return -ENOMEM; + } + spin_lock(&p->page_lock); temp = free_list.next; diff --git a/xen/common/domain.c b/xen/common/domain.c index 5fc4304c01..d8ea1078a6 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -161,8 +161,13 @@ unsigned int alloc_new_dom_mem(struct task_struct *p, unsigned int kbytes) spin_lock_irqsave(&free_list_lock, flags); /* is there enough mem to serve the request? */ - if ( req_pages > free_pfns ) return -1; - + if ( (req_pages + (SLACK_DOMAIN_MEM_KILOBYTES << (PAGE_SHIFT-10))) > + free_pfns ) + { + spin_unlock_irqrestore(&free_list_lock, flags); + return -1; + } + /* allocate pages and build a thread through frame_table */ temp = free_list.next; for ( alloc_pfns = 0; alloc_pfns < req_pages; alloc_pfns++ ) diff --git a/xen/include/xeno/config.h b/xen/include/xeno/config.h index 9dbceda88e..0623d607db 100644 --- a/xen/include/xeno/config.h +++ b/xen/include/xeno/config.h @@ -85,6 +85,12 @@ #define IOREMAP_VIRT_START (MAPCACHE_VIRT_END) #define IOREMAP_VIRT_END (IOREMAP_VIRT_START + (4*1024*1024)) +/* + * Amount of slack domain memory to leave in system, in megabytes. + * Prevents a hard out-of-memory crunch for thinsg like network receive. + */ +#define SLACK_DOMAIN_MEM_KILOBYTES 1024 + /* Linkage for x86 */ #define FASTCALL(x) x __attribute__((regparm(3))) #define asmlinkage __attribute__((regparm(0))) -- 2.30.2